<template>
  <div id="OrdersTitle">
    <v-details :inputConfig="inputConfig" :detailData="inputData" :rules="rules" ref="input" @changeData="changeData"></v-details>
    
  </div>
</template>

<script>
import details from 'commons/Detail'
import baseMixin from '@/mixins/BaseMixin'

export default {
  props: {
    inputData: {
      type: Object
    }
  },
  mixins: [baseMixin],
  name: 'OrdersTitle',
  data() {
    return {
      addflag: false,
      compantList:[]
    }
  },
  computed: {
    inputConfig() {
      return [
        [
          {
            type: 'input',
            label: this.$t('common.user'),
            props: 'username',
            disabled: this.addflag
          },
          {
            type: 'input',
            label: this.$t('common.pwd'),
            inputType: 'password',
            props: 'password'
          },
        ],
        [
          {
            type: 'input',
            label: this.$t('app.fullname'),
            props: 'fullname'
          },
          {
            type: 'input',
            label: this.$t('app.email'),
            props: 'email'
          },
          {
            type: 'select',
            label: "所属公司",
            props: 'compantId',
            options:this.compantList
          },
        ]
      ]
    },
    rules() {
      return {
        username: [{ required: true, trigger: 'blur' }],
        password: [{ required: true, trigger: 'blur' }],
        fullname: [{ required: true, trigger: 'blur' }],
      }
    }
  },
  methods: {
    changeData(data) {
      this.$parent.$parent.saveStatus = false
    },
    getOptions(){
      this.$post('/v1/edi/plCompany/selectPlCompany', {
        pageNum: 1,
        pageSize: 999
      }).then(res => {
        const data = res.data.item
        this.compantList = data.map(i => {
          i.description = i.companyName
          i.code = i.id
          return i
        })
      })
    }
  },
  mounted() {
    this.getOptions()
    if (Object.keys(this.$store.state.skip).length !== 0) {
      let data = this.$store.state.skip
      if (data.newFlag) {
        this.addflag = false
      } else {
        this.addflag = true
      }
    } else if (this.$store.state.newFlag) {
      this.addflag = false
    } else {
      this.addflag = true
    }
  },
  watch: {},
  components: {
    'v-details': details
  }
}
</script>

<style scoped></style>
